from xmlrpc.client import Boolean

import objectBase
import time

class SummonedBase(objectBase.ObjectBase):
    def __init__(self,surface,path,size,pos,speed,gap,liveTime,moveLength,atk) :
        self.liveTime = liveTime
        self.addTime = time.time()
        self.startPos = (pos[0],pos[1])
        self.moveLength = moveLength
        self.speed = speed
        self.surface = surface
        self.gap = gap
        self.atk = atk
        super().__init__(path,size,pos)

    def move(self) :
        if self.checkMove() :
            if self.speed[0] != 0:
                self.moveX(self.speed[0])
            if self.speed[1] != 0:
                self.moveY(self.speed[1])
        self.draw(self.surface)
        if self.gap > 0 :
            self.updateFileIndex(self.gap)


    def checkDead(self) :
        isDead = False
        if self.liveTime >= 0 and (time.time() - self.addTime > self.liveTime):
            isDead = True
        return isDead

    def checkMove(self) :
        canMove = True
        if self.pos[0] - self.startPos[0] > self.moveLength :
            canMove = False
        elif self.pos[0] - self.startPos[0] < -self.moveLength :
            canMove = False
        elif self.pos[1] - self.startPos[1] > self.moveLength :
            canMove = False
        elif self.pos[1] - self.startPos[1] < -self.moveLength :
            canMove = False
        return canMove